package com.ktjiaoyu.crm.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ktjiaoyu.crm.mapper.UserDao;
import com.ktjiaoyu.crm.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;


    @Override
    public User login(String usrName, String usrPassword) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("usr_name",usrName);
        queryWrapper.eq("usr_password",usrPassword);
        return userDao.selectOne(queryWrapper);
    }

    @Override
    public int addUser(User user) {
        return 0;
    }

    @Override
    public int deleteUser(Long usrId) {
        return 0;
    }

    @Override
    public int updateUser(User user) {
        return 0;
    }

    @Override
    public User getUser(Long usrId) {
        return userDao.selectById(usrId);
    }

    @Override
    public List<User> findAllUsers() {
        return userDao.selectList(null);
    }

    @Override
    public List<User> getUsersAndRole() {
        return userDao.getUsersAndRole();
    }
}
